﻿namespace OpenWaves.EPiServer.BrightcoveVideoCloudProperty
{
    public class QueryBuilder
    {
        public int ItemsPerPage { get; set; }

        public int PageNumber { get; set; }

        public string Phrase { get; set; }

        public QueryBuilder GetPage(int pageNumber)
        {
            PageNumber = pageNumber;
            return this;
        }

        public QueryBuilder SearchFor(string phrase)
        {
            Phrase = phrase;
            return this;
        }

        public QueryBuilder Take(int itemsPerPage)
        {
            ItemsPerPage = itemsPerPage;
            return this;
        }

        public Query ToQuery()
        {
            return new Query
                {
                    PageNumber = PageNumber,
                    ItemsPerPage = ItemsPerPage,
                    Phrase = Phrase
                };
        }

        public static QueryBuilder From(Query query)
        {
            return new QueryBuilder
                {
                    PageNumber = query.PageNumber,
                    ItemsPerPage = query.ItemsPerPage,
                    Phrase = query.Phrase
                };
        }
    }
}